import Entity.ClassEntity
import java.io.File
import java.nio.file.Paths

fun main(args: Array<String>) {

    //*********************************************************
    //定义执行前需要修改的变量
    val dirPath:String = "/home/milo/work/code/java/heap/out/production/heap"
    val mdFileName:String = "heap.md"
    //*********************************************************

    val classAnalyzer: ClassAnalyzer = ClassAnalyzer()
    classAnalyzer.loadClassFromDir(dirPath)
    val classEntities:List<ClassEntity> = classAnalyzer.getClassEntities()
    for (element in classEntities) {
        println(element.toString())
    }

    //保存uml图的根目录
    val umlHome:String = "/home/milo/note/我的笔记/Uml图";
    val mdFile = File(Paths.get(umlHome, mdFileName).toString())
    //写入文件，生成uml图文件
    mdFile.printWriter().use { out ->
        out.println("```mermaid")
        out.println("classDiagram")
        for (element in classEntities) {
            out.println(element.toString())
        }
        out.println("```")
    }
}